function [X, indices, size_image] = Struct2vec(x)
% [X, indices, size_image] = Struct2vec(x)
% 
% Struct2vec converts an image which is given as a struct to a vector. 
% As this conversion is lossy the missing information is stored in indices 
% and size_image.
%
% See also: Vec2struct, Im2struct, Struct2im 
%
% 2013-07-25 --------------------------------------------------------------
% 
% Matthias J. Ehrhardt
% CMIC, University College London, UK
% 
% matthias.ehrhardt.11@ucl.ac.uk
% 
% -------------------------------------------------------------------------

    K = length(x);
    size_image = size(x{1});
    N = prod(size_image);
    
    X = zeros(K*N, 1);
    indices = cell(K,1);
    
    for k = 1 : K
        indices{k} = (k-1)*N + (1:N);
        X(indices{k}) = Column(x{k});
    end
end

